/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rukopisyimport;

import java.io.File;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author Martin Rehanek (rehan@mzk.cz)
 */
public class TeiStructureDepthStatistics {

    private final Map<Integer, List<File>> depthFileListMap = new HashMap<Integer, List<File>>();

    public void printStatistics(PrintStream out, boolean detailed) {
        for (Integer depth : depthFileListMap.keySet()) {
            List<File> files = depthFileListMap.get(depth);
            out.println("depth " + depth + ": " + files.size());
            if (detailed) {
                printFiles(files, out);
            }
        }
    }

    public void updateStatistics(File file, int depth) {
        Integer depthInt = Integer.valueOf(depth);
        List<File> fileList = depthFileListMap.get(depthInt);
        if (fileList == null) {
            fileList = new ArrayList<File>();
            depthFileListMap.put(depthInt, fileList);
        }
        fileList.add(file);
    }

    private void printFiles(List<File> files, PrintStream out) {
        for (File file : files) {
            out.println(file);
        }
    }
}
